import time
from selenium.webdriver.common.by import By
from pages.basePage import BasePage

class registerPage(BasePage):
    # 注册按钮
    registerbutton = (By.XPATH, '//*[@id="ECS_MEMBERZONE"]/a[2]')
    # 用户名
    username = (By.XPATH, '// *[ @ id = "username"]')
    # email
    useremail = (By.XPATH, '//*[@id="email"]')
    # 输入密码
    password1 = (By.XPATH, '//*[@id="password1"]')
    # 确认密码
    password2 = (By.XPATH, '//*[@id="conform_password"]')
    # 输入QQ
    qq = (By.NAME, "extend_field2")
    # 入办公电话
    tel = (By.NAME, "extend_field3")
    # 输入家庭电话
    jiating = (By.NAME, "extend_field4")
    # 输入手机
    shurushouji = (By.NAME, "extend_field5")
    # 密码提示问题
    mimatishi = (By.NAME, "sel_question")
    # 选择问题
    xuanzewenti = (By.XPATH, "//*[@value='friend_birthday']")
    # 填写密保问题
    mibao = (By.NAME, "passwd_answer")
    # 点击会员注册
    vipregister = (By.NAME, "Submit")

    def register(slef, username, useremail, password1, password2, qq, tel, jiating, shurushouji, mibao, ):
        # slef.wd.get("http://192.168.110.134/")已经在firstpage中实例化了
        slef.getElement(slef.registerbutton).click()
        # slef.wd.find_element(*slef.registerbutton).click()
        slef.getElement(slef.username).send_keys(username)
        # slef.wd.find_element(*slef.username).send_keys(username)
        slef.getElement(slef.useremail).send_keys(useremail)
        # slef.wd.find_element(*slef.useremail).send_keys(useremail)
        slef.getElement(slef.password1).send_keys(password1)
        # slef.wd.find_element(*slef.password1).send_keys(password1)
        slef.getElement(slef.password2).send_keys(password2)
        # slef.wd.find_element(*slef.password2).send_keys(password2)
        slef.getElement(slef.qq).send_keys(qq)
        # slef.wd.find_element(*slef.qq).send_keys(qq)
        slef.getElement(slef.tel).send_keys(tel)
        # slef.wd.find_element(*slef.tel).send_keys(tel)
        slef.getElement(slef.jiating).send_keys(jiating)
        # slef.wd.find_element(*slef.jiating).send_keys(jiating)
        slef.getElement(slef.shurushouji).send_keys(shurushouji)
        # slef.wd.find_element(*slef.shurushouji).send_keys(shurushouji)
        slef.getElement(slef.mimatishi).click()
        # slef.wd.find_element(*slef.mimatishi).click()
        slef.getElement(slef.xuanzewenti).click()
        # slef.wd.find_element(*slef.xuanzewenti).click()
        slef.getElement(slef.mibao).send_keys(mibao)
        # slef.wd.find_element(*slef.mibao).send_keys(mibao)
        slef.getElement(slef.vipregister).click()
        # slef.wd.find_element(*slef.vipregister).click()
        time.sleep(3)
if __name__ == '__main__':
    R = registerPage().register(username="test01", useremail="2845621494@qq.com", password1="123456"
                            , password2="123456", qq="2845621494", tel="18439443346", jiating="12345678912"
                            , shurushouji="12345678912", mibao="815")

# R = registerPage().register(username="test01", useremail="2845621494@qq.com", password1="123456"
#                             , password2="123456", qq="2845621494", tel="18439443346", jiating="12345678912"
#                             , shurushouji="12345678912", mibao="815")
